package main

import (
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
)

//操作数据库
type Doctor struct {
	id      int
	name    string
	age     int
	sex     int
	addTime string
}

func main() {
	db, err := sql.Open("mysql", "ding:dyw20020304@tcp(81.68.186.20:3306)/Ding?charset=utf8&parseTime=True")
	if err != nil {
		fmt.Println("sql.Open err = ", err)
		return
	}
	defer db.Close()
	var doc Doctor
	Rows, err := db.Query("select * from doctor_tb")
	if err != nil {
		fmt.Println("sql.Open err = ", err)
		return
	}
	defer Rows.Close()
	for Rows.Next() {
		Rows.Scan(&doc.id, &doc.name, &doc.age, &doc.sex, &doc.addTime)
		fmt.Println(doc)
	}

}
